<template>
  <div class="about">
    <h1>注销页面，3秒后将跳回主页</h1>
  </div>
</template>
<script setup lang="ts">
import { useRouter } from "vue-router";
import { UserControllerService } from "../../../generated";
import message from "@arco-design/web-vue/es/message";
import { useStore } from "vuex";
import ACCESS_ENUM from "@/access/accessEnum";

const router = useRouter();
const store = useStore();

if (store.state.user.loginUser.userRole !== ACCESS_ENUM.NOT_LOGIN) {
  const res = await UserControllerService.userLogoutUsingPost();
  if (res.code === 0) {
    message.success("注销成功");
  } else {
    message.error("注销失败", res.message);
  }
  router.push({
    path: "/",
    replace: true,
  });
  window.location.reload();
  // setTimeout(() => {
  //
  // }, 3000);
} else {
  message.error("请先登录");
  router.push({
    path: "/",
    replace: true,
  });
}
</script>
